using UnityEngine;
using System.Collections;

public class HUD : MonoBehaviour {
	
	public Texture2D foto;
	string pokemon = "";
	public Texture2D vida;
	public int maxHealth = 100; 
	public int curhealth;
	public float healthBarLenght;
	public PokeBehave PokAtivo;
	
	bool selecionado = false;
	
	
	//public GameObject monstro;
	
	GUIStyle style = new GUIStyle();
	
	// Use this for initialization
	void Start () {
		
		healthBarLenght = Screen.width / 2;
	}
	
	// Update is called once per frame
	void Update () 
	{
		
		AddjustCurrentHealth();
		
		
	
		
		if(Input.GetKeyDown(KeyCode.Q))
		{
			selecionar(selecionado);
		}
		
		
	}
	
	void OnGUI()
	{
		if (pokemon == "")
		{
			GUI.Box(new Rect(10,10,100,90),"");
			GUI.Box(new Rect(10,105,100,20),"Pressione 'Q'"); 
		}
		else if(pokemon == "Bulbasauro")
		{
			//Foto e modelo
			GUI.Box(new Rect(10,10,100,90),foto);
			GUI.Box(new Rect(10,105,100,20),pokemon); 
			
			//Vida
			style.normal.background = vida;
			style.alignment = TextAnchor.MiddleCenter;
			GUI.Box(new Rect(120, 10, healthBarLenght, 20), (curhealth + "/" + maxHealth),style);
			
			//Ataques
			//Ataque 1
			GUI.Box(new Rect(10, Screen.height - 30, 25,25),"1");
			GUI.Box(new Rect(35, Screen.height - 30, 150, 25),"Tackle");
			//Ataque 2
			GUI.Box(new Rect(190, Screen.height - 30, 25,25),"2");
			GUI.Box(new Rect(215, Screen.height - 30, 150, 25),"Folha Navalha");
			//Ataque 3
			GUI.Box(new Rect(370, Screen.height - 30, 25,25),"3");
			GUI.Box(new Rect(395, Screen.height - 30, 150, 25),"Chicote de Vinha");
		}
		
		//Pokemon 1
		GUI.Box(new Rect(Screen.width-50,10,50,50),"");
		GUI.Box(new Rect(Screen.width-50,65,50,50),""); 
		GUI.Box(new Rect(Screen.width-50,120,50,50),""); 
		GUI.Box(new Rect(Screen.width-50,175,50,50),""); 
		GUI.Box(new Rect(Screen.width-50,230,50,50),""); 
		GUI.Box(new Rect(Screen.width-50,285,50,50),""); 
		
		
		
		
	}
	
	void selecionar (bool selecao)
	{
		
		if(selecao)
		{
			pokemon = "";
			PokAtivo.ativo = false;
			selecionado = false;
		}
		else
		{
			pokemon = "Bulbasauro";
			PokAtivo.ativo = true;
			selecionado = true;	
		}
			
		
	}
		
	
	
	public void AddjustCurrentHealth() 
	{
		if(curhealth > 20)
		{
   	 		healthBarLenght = (Screen.width / 4) * (curhealth / (float)maxHealth);
			
		}
		else
		{
			healthBarLenght = 60;
		}
	}
		
}
